﻿#include "updateExe.h"

UpdateExe::UpdateExe()
{

}


QString UpdateExe::selectFilePath(){

    _newFilePath = QFileDialog::getOpenFileName(nullptr, tr("Open Update File"), "", tr("Excel Files (*.exe)"));
    return _newFilePath;

}


QString UpdateExe::execUpdate(){


    if(!QFile::exists(_newFilePath)){
        return "选择的文件无效";
    }

    // 校验更新程序是否还活着
    if(!QFile::exists("./update.exe")){
        QFile::copy(":/src/update.exe", "./update.exe");
    }

    WinExec(("update.exe " + _newFilePath + " NIDCS.exe").toLatin1(), SW_SHOWNORMAL);

//    exit(0);
    return "";

}
